package cn.com.web.Servlet;

import cn.com.domain.Customer;
import cn.com.service.CustomerService;
import cn.com.service.impl.CustomerServiceImpl;

import javax.mail.Session;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/ShowCustomerServlet")
public class ShowCustomerServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CustomerService cs=new CustomerServiceImpl();
        List<Customer> customers = cs.findAll();
        request.setAttribute("customers",customers);
        request.getRequestDispatcher("Customer.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
